package objetosGraficos;

import java.awt.Dimension;
import java.awt.Font;
import java.awt.Point;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

import frame.FrameJuego;


public class anuncio extends JLabel implements Runnable  {

	private int w, h;
	private JPanel panelJuego;
	private FrameJuego juego;
	
	public anuncio (int w, int h,FrameJuego juego, JPanel panelJuego){
		this.setFont(new Font("Starcraft",Font.PLAIN,20));
		this.setHorizontalAlignment(SwingConstants.CENTER);
		this.setVerticalAlignment(SwingConstants.CENTER);
		this.juego = juego;
		this.panelJuego = panelJuego;
		this.setOpaque(false);
		this.setPreferredSize(new Dimension(274,158));
		this.setSize(274,158);

		this.w = w;
		this.h = h;
	}

	public Point getPosicion (){
		int x1, y1;
		
		x1 = (w/2) - (this.getWidth()/2);
		y1 = (h/2) - (this.getHeight()/2);
		
		return new Point (x1,y1);
	}
	public void run (){

		try {
			Thread.sleep(1500);
			panelJuego.repaint();
			while (this.getY() < h + this.getHeight()){
				Thread.sleep(10);
				this.setLocation(this.getX(),this.getY() + 3);
				panelJuego.repaint();
			}
			
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	
	}
	
}
